﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BUS;
using DAO; 

namespace CameraProjects
{
    public partial class Template : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
             
        }

        protected void btnTimKiem_Click(object sender, EventArgs e)
        {
            string tukhoa = Utils.ConvertToUnSign( txtTuKhoa.Text.Trim()).ToLower();
            int giatrichon= int.Parse(ddlCategory.SelectedValue.ToString()); // lay gia tri dc chon o combobox
            if(giatrichon == 0 || giatrichon==1)
            {
                // load camera
                CameraBUS cBUS = new CameraBUS();
                List<Camera> list= new List<Camera>();
                DanhMuc.ListCamera = cBUS.GetListSearch(tukhoa);
                Response.Redirect("/DanhMuc.aspx?cate=camera");

            }
            else if(giatrichon==2)
            {
                //load acc 
                AccessoriesBUS cBUS = new AccessoriesBUS();
                List<Accessory> list = new List<Accessory>();
                DanhMuc.ListAccessory = cBUS.GetListSearch(tukhoa);
                Response.Redirect("/DanhMuc.aspx?cate=accessories");
            }
            else
            {
                // load lens
                LensBUS cBUS = new LensBUS();
                List<Lens> list = new List<Lens>();
                DanhMuc.ListLens = cBUS.GetListSearch(tukhoa);
                Response.Redirect("/DanhMuc.aspx?cate=lens");
            }
        } 
    }
}